package com.aliyun.heiyu.powermaster.server.dao.impl;

import com.aliyun.heiyu.powermaster.server.dao.ArmStateGridCollectInfoDao;
import com.aliyun.heiyu.powermaster.server.rbac.utils.JdbcUtil;

import java.util.Map;

public class ArmStateGridCollectInfoDaoImpl implements ArmStateGridCollectInfoDao {

    @Override
    public Map<String, String> getArmStateGridCollectInfo(String sn) {
        Object[] params = new Object[1];
        params[0] = sn;
        String sql =" select  id,\n" +
            " gmt_create,\n" +
            " gmt_modified,\n" +
            " collect_time,\n" +
            " frame_power,\n" +
            " server_power,\n" +
            "  cpu_freq,\n" +
            "  cpu_usage,\n" +
            " server_sn,\n" +
            " inlet_temp,\n" +
            " outlet_temp,\n" +
            " cpu_temp,\n" +
            " dimmg_temp,\n" +
            " fan_rpm,\n" +
            " ps_power,\n" +
            " pch_temp,\n" +
            " nvme_temp,\n" +
            " cpu_margin_temp,\n" +
            " cpu_vr_temp,\n" +
            " ps_status,\n" +
            " total_memory,\n" +
            " nvme_temp_max network_read,\n" +
            " cpu_voltage,\n" +
            " iowait,\n" +
            " available_memory,\n" +
            " network_write from  state_grid_collect_info  WHERE server_sn=? ORDER BY id DESC LIMIT 0,1";
        Map<String, String> map = JdbcUtil.queryForMap(sql, params);
        return map;
    }
    @Override
    public Map<String, String> findBySn(String sn, Integer position){
        Object[] params = new Object[2];
        params[0] = sn;
        params[1] = position;
        String sql =" select  id,\n" +
            " gmt_create,\n" +
            " gmt_modified,\n" +
            " collect_time,\n" +
            " frame_power,\n" +
            " server_power,\n" +
            "  cpu_freq,\n" +
            "  cpu_usage,\n" +
            " server_sn,\n" +
            " inlet_temp,\n" +
            " outlet_temp,\n" +
            " cpu_temp,\n" +
            " dimmg_temp,\n" +
            " fan_rpm,\n" +
            " ps_power,\n" +
            " pch_temp,\n" +
            " nvme_temp,\n" +
            " cpu_margin_temp,\n" +
            " cpu_vr_temp,\n" +
            " ps_status,\n" +
            " total_memory,\n" +
            " nvme_temp_max network_read,\n" +
            " cpu_voltage,\n" +
            " iowait,\n" +
            " available_memory,\n" +
            " network_write from  state_grid_collect_info  WHERE server_sn=? ORDER BY id DESC LIMIT ?,1";
        Map<String, String> map = JdbcUtil.queryForMap(sql, params);
        return map;
    }
}
